using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace EFDataBase.Models.Mapping
{
    public class ProductMap : EntityTypeConfiguration<Product>
    {
        public ProductMap()
        {
            // Primary Key
            this.HasKey(t => t.product_id);

            // Properties
            this.Property(t => t.product_id)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.parent_id)
                .HasMaxLength(50);

            this.Property(t => t.product_name)
                .HasMaxLength(50);

            this.Property(t => t.range)
                .IsFixedLength()
                .HasMaxLength(10);

            this.Property(t => t.productset)
                .HasMaxLength(50);

            this.Property(t => t.Go_online)
                .IsFixedLength()
                .HasMaxLength(10);

            this.Property(t => t.deletes)
                .IsFixedLength()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Product");
            this.Property(t => t.product_id).HasColumnName("product_id");
            this.Property(t => t.parent_id).HasColumnName("parent_id");
            this.Property(t => t.product_name).HasColumnName("product_name");
            this.Property(t => t.range).HasColumnName("range");
            this.Property(t => t.productset).HasColumnName("productset");
            this.Property(t => t.Go_online).HasColumnName("Go_online");
            this.Property(t => t.Go_onlinetime).HasColumnName("Go_onlinetime");
            this.Property(t => t.deletes).HasColumnName("deletes");
            this.Property(t => t.createtime).HasColumnName("createtime");
        }
    }
}
